package com.niu.controller;

import com.niu.pojo.MyResult;
import com.niu.service.FileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * @Author 鹅鹅鹅
 * @Version 1.0.0
 * @Date 2025/7/16 17:43
 * @Description 员工头像上传功能
 */

@RestController
public class EmpUploadController {

    @Autowired
    private FileService fileService;

    // 上传文件到云存储
    @PostMapping("/upload")
    public MyResult<String> uploadToOss(MultipartFile image){
        String s = fileService.saveFileToOss(image);
        return s != null || s != "" ? MyResult.ok(s) : MyResult.error("文件上传失败");
    }
}
